|----------------------------------------------|
| Status Timers Hack                           |
| by: madsiur                                  |
| version: 1.0                                 |
| Released on: February 14th, 2022             |
| apply to: FF3us 1.0 (no header)              |
|----------------------------------------------|

|----------------------------------------------|
| Files                                        |
|----------------------------------------------|

status-timers-nh.ips: IPS patch for vanilla ROM
status-timers.asm: bass assembly file of the above hack

status-timers-stop-nh.ips: IPS patch for Independent Stop/Premature Continuation fix compatibility
status-timers-stop.asm: bass assembly file of the above hack

|----------------------------------------------|
| Description                                  |
|----------------------------------------------|

This hack add timers for Slow, Haste, Safe and  Shell
when casted on characters or monsters. It use 4 free bits
on the expired status byte ($B8) plus a byte per monster
and character for each of the 4 new timers ($3E38, $3E39,
$3E88 and $3E89). Right now, there is no easy way to know
when those 4 timed status are lifted on a monster but that
will be deal with in another hack. All 4 timers have a 
value of $1E, so they last longer than Reflect but shorter 
than Freeze. The new timer values can individually be 
edited in the bass asm file.

There are two hacks; "status-timers" is for vanilla ROM
and fix the same bug as "Premature Continuation fix" by
assassin (link below), only it does at a different place 
in the code. "status-timers-stop" implement the "Independent
Stop" code by seibaby (link below) as well as the original 
"Premature Continuation fix" by assassin. Use "status-timers-stop"
if you already have applied or want to apply those two hacks.

Both hacks use 202 ($CA) bytes of free space at $EEAF01.
This free space offsets can be changed in the bass asm file
by changing the offset of the "seek($EEAF01)" macro call.
Both hacks use no free space in bank $C2 but instead relocate
the "check timers" routine from $C25B06 to $EEAF01 to make
room for the new "set Slow/Haste/Safe/Shell" bank $C2 code.

To assemble the hack use bass v14 by typing a command
such as "bass -o rom.smc status-timers.asm".

|----------------------------------------------|
| Timers length (reference)                    |
|----------------------------------------------|

Sleep:      $12 (original)
Stop:       $12 (original)
Reflect:    $1A (original)
Slow:       $1E (new)
Haste:      $1E (new)
Shell:      $1E (new)
Safe:       $1E (new)
Freeze:     $22 (original)

|----------------------------------------------|
| RAM changes (previously unused)              |
|----------------------------------------------|

$B8: Current entity's expired status byte
bit 0: Stop     (original)
bit 1: Reflect  (original)
bit 2: Freeze   (original)
bit 3: Sleep    (original)
bit 4: Haste    (new)
bit 5: Slow     (new)
bit 6: Shell    (new)
bit 7: Safe     (new)

$3E38,x: current entity's Slow timer
$3E39,x: current entity's Haste timer
$3E88,x: current entity's Shell timer
$3E89,x: current entity's Safe timer

|----------------------------------------------|
| Links                                        |
|----------------------------------------------|

bass v14:
https://www.romhacking.net/utilities/794/

Premature Continuation fix:
http://assassin17.brinkster.net/patches.htm#anchor27
`
Independent Stop:
https://www.ff6hacking.com/forums/thread-3389.html